package com.anche.cywebnew.Utils.query;

import com.alibaba.fastjson2.JSONObject;


public class MakeToken
{
	private static String URL = "http://56.32.4.182:8021/sms-boot/sys/smsLoginInterface";
	
	public static void main(String[] args)
	{
		String token = getToken("用户名", "密码");
		System.out.println(token);
	}
	
	public static String getToken(String userName, String passWord)
	{
		JSONObject param = new JSONObject();
		param.put("userName", userName);
		param.put("passWord", passWord);
		
		String token = "0";
		String response = HttpUtil.post(URL, param.toString());
		JSONObject obj = JSONObject.parseObject(response);
		/*
		 * {"success":true,"message":"登录成功","code":200,"result":{"token":"TOKEN"},"timestamp":1697167195348}
		 */
		if (200 == obj.getIntValue("code"))
		{
			JSONObject result = obj.getJSONObject("result");
			token = result.getString("token");
		}
		
		return token;
	}
}
